<template>
<Table :columns="columns" :data="data" />
</template>

<script>
import { Table } from 'iview';
import config from '@/config';

export default {
  props: ['items'],
  components: {
    [Table.name]: Table
  },
  data() {
    return {
      config,
      columns: [
        {title: 'ID', key: 'user_order_products_id', align: 'center'},
        {title: '数量', key: 'amount', align: 'center'},
        {title: '人民币价格', key: 'price_rmb', align: 'center'},
        {title: '零售积分', key: 'price_retail', align: 'center'},
        {title: '商品价格', key: 'price_shop', align: 'center'},
        {title: '图片', key: 'images', align: 'center', render: (h, params) => {
          var images = JSON.parse(params.row.images);
          if(typeof(images[0]) !== 'undefined') {
            return h('img', {attrs:{src:config.uploadUrl + images[0]},style:{height:'100px'}});
          } else {
            return h('img', {attrs:{src:'http://iph.href.lu/100x100?text=%E6%97%A0%E5%9B%BE%E7%89%87'}});
          }
        }},
      ],
      data: this.$props.items
    };
  }
};

</script>
